package com.sky.web.admin;

import com.sky.result.Result;
import com.sky.service.ReportService;
import com.sky.vo.BusinessDataVO;
import com.sky.vo.DishOverViewVO;
import com.sky.vo.OrderOverViewVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

@RestController
@Slf4j
@RequestMapping("/admin/workspace")
public class WorkSpaceController {

    @Autowired
    private ReportService reportService;

    // 今日数据
    @GetMapping("/businessData")
    public Result businessData() {
        LocalDate today = LocalDate.now();
        BusinessDataVO vo = reportService.businessData(today);
        return Result.success(vo);
    }

    // 今日订单
    @GetMapping("/overviewOrders")
    public Result overviewOrders() {
        LocalDate today = LocalDate.now();
        OrderOverViewVO vo = reportService.overviewOrders(today);
        return Result.success(vo);
    }

    //菜品总览
    @GetMapping("/overviewDishes")
    public Result overviewDishes() {
        String table = "dish";
        DishOverViewVO vo = reportService.dishAndSetmealOverview(table);
        return Result.success(vo);
    }

    //套餐总览
    @GetMapping("/overviewSetmeals")
    public Result overviewSetmeals() {
        String table = "setmeal";
        DishOverViewVO vo = reportService.dishAndSetmealOverview(table);
        return Result.success(vo);
    }
}
